#include "BDStartDialog.h"
#include "BDResourceUtil.h"
#include "mmcogtest.h"
#include "UIReceiver.h"
#include "mmcogtestmsg.h"
#include "UISender.h"



BDStartDialog::BDStartDialog(QWidget *parent)
	: QDialog(parent)
{
	ui.setupUi(this);
	connect(UIReceiver::GetInstance(), SIGNAL(QTestInitialResult(const QVector<QString>&)), this, SLOT(OnTestInitialResult(const QVector<QString>&)));
	UISender sender;
	sender.SendInitTest();
	sender.SendVoicePlay("b.wav");
}

BDStartDialog::~BDStartDialog()
{

}

void BDStartDialog::InitCombox()
{

}

void BDStartDialog::OnTestInitialResult(const QVector<QString>& tests)
{
	int num = 0;
	for (int i = 0; i < tests.size(); ++i) {
		QPushButton* button = new QPushButton(tests[i], this);
		m_vecButton.push_back(button);
		button->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
		ui.layout->addWidget(button, num / 3, num % 3);
		connect(button, SIGNAL(clicked()), this, SLOT(OnTestButtonClicked()));
		num++;
	}
}

void BDStartDialog::OnTestButtonClicked()
{
	int num = m_vecButton.indexOf((QPushButton*)sender(), 0);
	m_MainWindow = new BDMainWindow(num);
	m_MainWindow->show();
}